package com.motu.monstercity.server.game.logic;

import com.motu.monstercity.protocol.Common.PBUserData;
import com.motu.monstercity.server.game.base.CommonUtils;
import com.motu.monstercity.server.game.base.ProtoDataUtils;
import com.motu.monstercity.server.game.commondata.partner.PartnerMain;
import com.motu.monstercity.server.game.commondata.suit.Suit;
import com.motu.monstercity.server.game.log.MotuLogManager;
import com.motu.monstercity.server.game.userdata.*;
import io.vertx.core.json.JsonArray;

public class SuitManager extends SuitUserData {
    // 初始化下发服装模块的用户数据
    public static void loadInitSuitUserData(PBUserData.Builder pbUserData, UserInfo userInfo) {
        long userId = userInfo.getId();
        for (UserSuit userSuit : getUserSuitList(userId)) {
            ProtoDataUtils.updatePBUserData(pbUserData, userSuit, true);
        }
    }

    // 获得角色皮肤/服装 只支持一次获得1个
    public static void addRewardSuit(UserInfo userInfo, int suitId, long num, PBUserData.Builder pbUserData, Object... logParams) {
        long userId = userInfo.getId();
        Suit suit = getSuit(suitId);
        if (suit == null) {
            return;
        }
        UserSuit userSuit = getUserSuit(userId, suitId);
        if (userSuit != null) {
            return;
        }
        userSuit = new UserSuit(userId, suitId, suit.getFirstLevel());
        userSuit.doCreate();
        MotuLogManager.logItemIncome(userInfo, suitId, 0, 0, 1, logParams);// 记录获得日志
        if (pbUserData != null) {
            ProtoDataUtils.updatePBUserData(pbUserData, userSuit);
        }
    }
}
